package com.neu.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.neu.po.ResponseResult;
import com.neu.po.Roomdue;
import com.neu.po.Roominfo;
import com.neu.service.RoominfoService;

@RestController
@RequestMapping("roominfo")
public class RoominfoController {
	
	@Autowired
	private RoominfoService  roominfoService;
	
	
	
	
	//条件分页
	@RequestMapping("pageinfo")
	public ResponseResult pageinfo(int pageNum ,int pageSize,String roomid,String louceng,Date dates) {
		ResponseResult rsule =new ResponseResult();
		
		PageInfo<Roominfo> list = roominfoService.getRoomInfo(pageNum, pageSize,roomid,louceng,dates);
		rsule.setData(list);
		return rsule;
	}
	//插入预定单
	@RequestMapping("insertroomdue")
	public ResponseResult insertroomdue(@RequestBody Roomdue type) {
		ResponseResult rsule =new ResponseResult();
		type.setDelmark(1);
		int i = roominfoService.insert(type);
		rsule.setData(i);
		return rsule;
	}
	//按时间查询预订单
	@RequestMapping("selectTime")
	public ResponseResult selectTime(String infodate) {
		ResponseResult rsule =new ResponseResult();
		
		
		rsule.setData(roominfoService.selectTime(infodate.substring(0,10)));
		return rsule;
	}
	//修改预定表
	@RequestMapping("update")
	public ResponseResult update(@RequestBody Roomdue type) {
		ResponseResult rsule =new ResponseResult();
		type.setDelmark(1);
		int i = roominfoService.updates(type);
		rsule.setData(i);
		return rsule;
	}
	//删除预定数据
	@RequestMapping("delete")
	public ResponseResult delete(int id) {
		ResponseResult rsule =new ResponseResult();
		int i = roominfoService.delete(id);
		rsule.setData(i);
		return rsule;
	}
	
}
